﻿package  {
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;

    public class EipBar extends EipbarBase {

        private var _onSendEip:Function;
        private var _btnList:Array;

        public function EipBar(){
            this._onSendEip = new Function();
            super();
            this.renderEip();
        }
        public function set onSendEip(_arg1:Function):void{
            this._onSendEip = _arg1;
        }
        public function clear():void{
            var _local3:Object;
            var _local1:int = this._btnList.length;
            var _local2:int;
            while (_local2 < _local1) {
                _local3 = this._btnList[_local2];
                _local3.btn.removeEventListener(MouseEvent.CLICK, _local3.eipClick);
                _local3.btn.removeEventListener(MouseEvent.MOUSE_OVER, _local3.eipMouseOver);
                _local3.btn.removeEventListener(MouseEvent.MOUSE_OUT, _local3.eipMouseOut);
                _local3.btn.removeChild(_local3.eip);
                _local3.eip = null;
                removeChild(_local3.btn);
                _local3.btn = null;
                _local2++;
            };
            this._btnList = null;
        }
        private function renderEip():void{
            var _eipData:Object;
            var _eip:EipBtn;
            var _eipIndexSuffix:int;
            var _eipName:String;
            var _eipClass:Class;
            var _eipIcon:MovieClip;
            this._btnList = [];
            var _eipIndex:int;
            while (_eipIndex < 25) {
                _eipData = {};
                _eip = new EipBtn();
                _eip.x = 1 + (_eip.width + 5) * (_eipIndex - 5 * Math.floor(_eipIndex / 5));
                _eip.y = 1 + Math.floor(_eipIndex / 5) * (_eip.height + 5);
                _eip._Black.alpha = 0;
                _eip.buttonMode = true;
				_eip.doubleClickEnabled = false;
				_eip.mouseEnabled = true;
				_eip.mouseChildren = false;
                addChild(_eip);
                _eipIndexSuffix = (_eipIndex + 1);
                _eipName = ("eip" + _eipIndexSuffix);
                _eipClass = (getDefinitionByName(_eipName) as Class);
                _eipIcon = (new (_eipClass)() as MovieClip);
                _eip.addChild(_eipIcon);
				_eipData.name = _eipName;
                _eipData.eip = _eipIcon;
                _eipData.btn = _eip;
                _eipData.id = _eipIndexSuffix;
                _eipData.eipClick = this.eipClick(_eipData);
                _eipData.eipMouseOver = this.eipMouseOver(_eipData);
                _eipData.eipMouseOut = this.eipMouseOut(_eipData);
                _eipData.btn.addEventListener(MouseEvent.CLICK, _eipData.eipClick);
                _eipData.btn.addEventListener(MouseEvent.MOUSE_OVER, _eipData.eipMouseOver);
                _eipData.btn.addEventListener(MouseEvent.MOUSE_OUT, _eipData.eipMouseOut);
                this._btnList.push(_eipData);
                _eipIndex++;
            };
        }
        private function eipClick(_arg1:Object):Function{
            var data:* = _arg1;
            var func:* = function (_arg1:MouseEvent):void{
                _onSendEip(data);
            };
            return (func);
        }
        private function eipMouseOver(_arg1:Object):Function{
            var data:* = _arg1;
            var func:* = function (_arg1:MouseEvent):void{
                data.btn._Black.alpha = 1;
            };
            return (func);
        }
        private function eipMouseOut(_arg1:Object):Function{
            var data:* = _arg1;
            var func:* = function (_arg1:MouseEvent):void{
                data.btn._Black.alpha = 0;
            };
            return (func);
        }

    }
}//package 
